home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TextEditorSemIntf.cpp
-
- Contains: TextEditor Apple Event interface
-
- Written by: Steve Smith
-
- Copyright: © 1994 - 1995 by Apple Computer, Inc., all rights reserved.
- */
-
-
- #define VARIABLE_MACROS
- #define TextEditorSemIntf_Class_Source
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _EXCEPT_
- // Exceptions define several important macros (e.g. CHECKENV)
- // which are used in the SOM method dispatch glue. If Except.h
- // is not included early enough, exceptions may not be thrown
- // correctly when returning from a SOM method with "ev" parameter set.
- #include <Except.h>
- #endif
-
- // -- TextEditorSemIntf Includes --
-
- #ifndef SOM_TextEditorSemIntf_xih
- #include "TextEditorSemIntf.xih"
- #endif
-
- // -- TextEditor Includes --
-
- #ifndef SOM_SampleCode_TextEditor_xh
- #include "TextEditor.xh"
- #endif
-
- #ifndef _TEXTEDITORGLOBALS_
- #include "TextEditorGlobals.h"
- #endif
-
- #ifndef _TEXTEDITORUTILS_
- #include "TextEditorUtils.h"
- #endif
-
- // -- Textension Includes --
-
- #ifndef _TSMTextension_
- #include "TSMTextension.h"
- #endif
-
- // -- OpenDoc Includes --
-
- #ifndef SOM_ODPart_xh
- #include <Part.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_ODOSLToken_xh
- #include <ODOSLTkn.xh>
- #endif
-
- #ifndef SOM_ODAppleEvent_xh
- #include <ODAplEvt.xh>
- #endif
-
- // -- OpenDoc Utilities --
-
- #ifndef _FOCUSLIB_
- #include <FocusLib.h>
- #endif
-
- #ifndef _ODDESUTL_
- #include <ODDesUtl.h>
- #endif
-
- #ifndef _ODUTILS_
- #include <ODUtils.h>
- #endif
-
- #ifndef _TEMPOBJ_
- #include <TempObj.h>
- #endif
-
- // -- Toolbox Includes --
-
- #ifndef __APPLEEVENTS__
- #include <AppleEvents.h>
- #endif
-
- #ifndef __AEOBJECTS__
- #include <AEObjects.h>
- #endif
-
- #ifndef __AEPACKOBJECT__
- #include <AEPackObject.h>
- #endif
-
- #ifndef __TEXTSERVICES__
- #include <TextServices.h>
- #endif
-
- #pragma segment TextEditorSemanticInterface
-
- //------------------------------------------------------------------------------
- // Method: RegisterTextension
- // Origin: TextEditorSemIntf
- //------------------------------------------------------------------------------
- SOM_Scope void SOMLINK TextEditorSemIntf__RegisterTextension(TextEditorSemIntf *somSelf, Environment *ev,
- ODPtr textension)
- {
- TextEditorSemIntfData *somThis = TextEditorSemIntfGetData(somSelf);
- TextEditorSemIntfMethodDebug("TextEditorSemIntf","RegisterTextension");
-
- _fTextension = (CTSMTextension*) textension;
- }
-
- //------------------------------------------------------------------------------
- // Method: somInit
- // Origin: SOMObject
- //------------------------------------------------------------------------------
- SOM_Scope void SOMLINK TextEditorSemIntf__somInit(TextEditorSemIntf *somSelf)
- {
- TextEditorSemIntfData *somThis = TextEditorSemIntfGetData(somSelf);
- TextEditorSemIntfMethodDebug("TextEditorSemIntf","somInit");
-
- _fTextension = kODNULL;
- }
-
- //------------------------------------------------------------------------------
- // Method: somUninit
- // Origin: SOMObject
- //------------------------------------------------------------------------------
- SOM_Scope void SOMLINK TextEditorSemIntf__somUninit(TextEditorSemIntf *somSelf)
- {
- TextEditorSemIntfMethodDebug("TextEditorSemIntf","somUninit");
- }
-
- //------------------------------------------------------------------------------
- // Method: CallEventHandler
- // Origin: ODSemanticInterface
- //------------------------------------------------------------------------------
- SOM_Scope void SOMLINK TextEditorSemIntf__CallEventHandler(TextEditorSemIntf *somSelf, Environment *ev,
- ODPart* thePart,
- ODAppleEvent* theODAppleEvent,
- ODAppleEvent* reply)
- {
- TextEditorSemIntfData *somThis = TextEditorSemIntfGetData(somSelf);
- TextEditorSemIntfMethodDebug("TextEditorSemIntf","CallEventHandler");
-
- SOM_TRY
-
- AppleEvent aeEvent = {typeNull, NULL};
- AppleEvent aeReply = {typeNull, NULL};
- TempODFrame keyFrame = kODNULL;
- ODPart* realPart = kODNULL;
-
- ODVolatile(realPart);
-
- TRY
- keyFrame = ODGetSession(ev, thePart)->GetArbitrator(ev)
- ->AcquireFocusOwner(ev, gGlobals->fKeyFocus);
-
- CFrameInfo* frameInfo = (CFrameInfo*) keyFrame->GetPartInfo(ev);
- ODFacet* facet = frameInfo->GetActiveFacet();
-
- // Focus for drawing because Textension will draw the inline hole
- // feedback.
- CFocus intiateDrawing(ev, facet);
-
- THROW_IF_ERROR( ODDescToAEDesc(theODAppleEvent, &aeEvent) );
- THROW_IF_ERROR( ODDescToAEDesc(reply, &aeReply) );
-
- // Let Textension handle the Apple Event.
- THROW_IF_ERROR(_fTextension->ProcessAppleEvent(&aeEvent, &aeReply, 0));
-
- THROW_IF_ERROR( AEDescToODDesc(&aeReply, reply) );
-
- // If the event was handled, dirty the document.
- // The part passed to this method is actually the partwrapper for
- // the editor, so we need to get the "real" part to call methods
- // of it.
- realPart = thePart->GetRealPart(ev);
- ((SampleCode_TextEditor*) realPart)->HandleChange(ev);
- thePart->ReleaseRealPart(ev);
-
- CATCH_ALL
- if ( realPart )
- thePart->ReleaseRealPart(ev);
- AEDisposeDesc(&aeEvent);
- AEDisposeDesc(&aeReply);
- RERAISE;
- ENDTRY
-
- AEDisposeDesc(&aeEvent);
- AEDisposeDesc(&aeReply);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
-
-
-